package com.jingdianjichi.wx.handler;

import com.jingdianjichi.wx.enums.WxMspTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * WxSubscribeHandler 类
 *
 * @author 熊苏鹏1
 * @date 2025/3/3 21:14
 * @description
 */
@Slf4j
@Component
public class WxSubscribeHandler implements WxTypeHandler{
    @Override
    public WxMspTypeEnum getType() {
        return WxMspTypeEnum.SUBSCIBE;
    }

    @Override
    public String dealMsg(Map<String, String> messageMap) {
        log.info("触发用户关注事件！");
        String fromUserName = messageMap.get("FromUserName");
        String toUserName = messageMap.get("ToUserName");
        String subscribeContent = "感谢您的关注，我是经典鸡翅！欢迎来学习从0到1社区项目";
        String content = "<xml>\n" +
                "  <ToUserName><![CDATA[" + fromUserName + "]]></ToUserName>\n" +
                "  <FromUserName><![CDATA[" + toUserName + "]]></FromUserName>\n" +
                "  <CreateTime>12345678</CreateTime>\n" +
                "  <MsgType><![CDATA[text]]></MsgType>\n" +
                "  <Content><![CDATA[" + subscribeContent + "]]></Content>\n" +
                "</xml>";
        return content;

    }
}
